home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Singles Flirt Up Your Life! (German)
/
Singles Flirt Up Your Life.iso
/
data1.cab
/
Statemachine
/
bookshelf.lua
< prev
next >
Wrap
Text File
|
2004-01-29
|
3KB
|
81 lines
-- bookshelf state machine
beginStateMachine()
onMsg("buildMenu", function(msg)
if (repairMenu()) then return end
-- build the pie menu
clearPieMenu();
local button;
button = addPieMenuButton("pm_takeBoardgame", "takeBoardgame");
button.addDescription(ACTIVITY, "playBoardgame");
button = addPieMenuButton("pm_takeNovel", "takeBook", "Novel");
button.addDescription(ACTIVITY, "readNovel");
button = addPieMenuButton("pm_takeSpecBook", "takeBook", "SpecBook");
button.addDescription(ACTIVITY, "readSpecBook");
end )
onMsg("takeBoardgame", function(msg)
-- get the game object server
local gameObjectServer = getGameObjectServer();
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
-- walk to the closest action point
local actionPoint = character.getFreeActionPoint(this, "take1");
-- get the walk state object
local wso = character.walkSO;
if (actionPoint) then
-- create state machine contexts
local wsoContext = StateMachineContext();
-- store the action point
wsoContext.storeData("actionPointName", actionPoint.getName());
wsoContext.storeStateObject("bookshelf", this);
if (wso.walkToActionPoint(actionPoint)) then
wso.queueStateMachine("bookshelfChar.takeBoardgame", this, wsoContext);
else
print("no path found");
instantAbort(character, EMOTICON_NOPATH, "emoThink")
end
else
print("no action point found");
instantAbort(character, EMOTICON_CANNOT, "emoThink")
end
end )
onMsg("takeBook", function(msg)
-- get the game object server
local gameObjectServer = getGameObjectServer();
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
-- walk to the closest action point
local actionPoint = character.getFreeActionPoint(this, "take1");
-- get the walk state object
local wso = character.walkSO;
if (actionPoint) then
-- create state machine contexts
local wsoContext = StateMachineContext();
-- store the action point
wsoContext.storeData("actionPointName", actionPoint.getName());
wsoContext.storeData("bookType", msg.data);
wsoContext.storeStateObject("bookshelf", this);
if (wso.walkToActionPoint(actionPoint)) then
wso.queueStateMachine("bookshelfChar.takeBook", this, wsoContext);
else
print("no path found");
instantAbort(character, EMOTICON_NOPATH, "emoThink")
end
else
print("no action point found");
instantAbort(character, EMOTICON_CANNOT, "emoThink")
end
end )
endStateMachine()